package com.lottery.ruok.lottrey.ui.component;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

import com.applozic.mobicomkit.contact.AppContactService;
import com.lottery.ruok.lottrey.R;
import com.lottery.ruok.lottrey.retrofitModule.response.GrabGiftHistoryResponse;

import butterknife.BindView;
import de.hdodenhof.circleimageview.CircleImageView;
import glideHelp.GlideHelper;

/**
 * 红包详情itemview
 */
public class GetRedPacketHistoryItemView extends BaseRelativeLayout {
    @BindView(R.id.logo)
    CircleImageView logo;
    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.time)
    TextView time;
    @BindView(R.id.money)
    TextView money;
    private GrabGiftHistoryResponse.ListBean data;
    private AppContactService appContactService;

    public GetRedPacketHistoryItemView(Context context) {
        super(context);
    }

    public GetRedPacketHistoryItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public GetRedPacketHistoryItemView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void init(Context context, AttributeSet attrs, int defStyleAttr) {

    }

    @Override
    protected void initView(Context context) {
        setContentView(R.layout.get_packet_child_item_history);
    }

    @Override
    protected void load(Context context) {

    }

    public void setData(AppContactService appContactService, GrabGiftHistoryResponse.ListBean data) {
        this.appContactService = appContactService;
        this.data = data;
        updateView();
    }

    private void updateView() {
        if (data != null) {
            GlideHelper.loadImage(mContext, data.getAvatar(), logo, R.mipmap.chat_default);
            name.setText(appContactService.getContactById(data.getNickname()).getDisplayName());
            time.setText(data.getUpdated_at());
            money.setText("￥" + data.getAmount());

        }
    }
}
